package com.abp.service.impl;

import com.abp.entity.BookLend;
import com.abp.entity.BookLibary;
import com.abp.entity.view.BookLendView;
import com.abp.mapper.BookLendMapper;
import com.abp.qpage.QPage;
import com.abp.service.IBookLendService;
import com.abp.utils.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 图书借出记录表 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-02-14
 */
@Service
public class BookLendServiceImpl extends ServiceImpl<BookLendMapper, BookLend> implements IBookLendService {


    /**
     * 分页查询
     * @param qPage
     * @return
     */
    @Override
    public IPage getPageList(QPage qPage, BookLendView obj) {
        IPage iPage = new Page(qPage.getPage(), qPage.getRows());
        List<BookLendView> mapList = this.baseMapper.getPageList(iPage,obj);
        return iPage.setRecords(mapList);
    }

    /**
     * 新增
     * @param obj
     * @return
     */
    @Override
    public Result insert(BookLend obj) {
        obj.setLendStatus(1);
        this.save(obj);
        return Result.reOk("恭喜，新增成功");
    }

    /**
     * 修改
     * @param obj
     * @return
     */
    @Override
    public Result updates(BookLend obj) {
        this.updateById(obj);
        return Result.reOk("恭喜，修改成功");
    }


}
